﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FurnitureSystem
{
    public partial class frmThongtinmuahang : Form
    {
        SqlConnection conn;
        SqlCommand cmd;
        SqlDataReader dr;
        public frmThongtinmuahang()
        {
            InitializeComponent();
        }

        private void frmThongtinmuahang_Load(object sender, EventArgs e)
        {
            

            int MaKH1 = Int32.Parse(frmQuanLyKH.MaKH);
            conn = connect.Getconect();
            conn.Open();
            string sql = "select Customer.Cust_name,Customer.Customerid,Customer.Contactno,Customer.Addr,Customer.Orderid,Orderline.Productid,Product.Productname,Type.Typeinfo,Orderline.Quantity,Orderline.Price from Customer,Orderline,Product,[Type] where Orderline.Orderid=Customer.Orderid and Orderline.Productid=Product.Productid and Product.Typeid=Type.Typeid and Customer.Orderid='" + MaKH1 + "'";
            cmd = new SqlCommand(sql, conn);
            dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                txtTenKH.Text = dr.GetString(0);
                txtMaKH.Text = dr.GetInt32(1).ToString();
                txtSDT.Text = dr.GetString(2);
                txtDiachi.Text = dr.GetString(3);
                txtMahoadon.Text = dr.GetInt32(4).ToString();  
                txtMasanpham.Text = dr.GetString(5);
                lbTensp.Text = dr.GetString(6);
                lbLoaisp.Text = dr.GetString(7);
                txtSoluong.Text = dr.GetInt32(8).ToString();
                txtSotien.Text = dr.GetInt32(9).ToString();
                
                conn.Close();
            }
            if (txtTenKH.Text == "")
            {

                
            }
            else
            {
                grThongtinkh.Visible = false;
                grThongtindonhang.Visible = false;
                lbXinloi.Visible = true;
                lbXinloi2.Visible = true;
                
            }

        }

        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

    }
}
